<?php

class ashop extends CI_Controller
{
    function index()
    {
        $this->pub->logq('index');
        $mid = $this->session->userdata('mid');
        $this->db->select('mid, nickname, headimgurl, tj_mid');
        $this->db->where('mid', $mid);
        $q = $this->db->get_where('member');
        $user = $q->row_array(0);


        $this->load->view('jdz/uc.php', $user);
    }

    function haibao($mid = 0)
    {
        if (mktime() > strtotime('2016-11-18 18:08:00')) {
            $mid = $mid ? $mid : $this->session->userdata('mid');
            $q = $this->db->get_where('member', array('mid' => $mid));
            $m = $q->row_array(0);
            if ($m['type'] == 3) {
                $back = $this->pub->haibao_dd($m);
                echo '<img style="width:100%;height:100%;margin:0;padding:0;" src="' . $back['url'] . '">';
            } else {
                $da['msg'] = '购买一件商品才可以生成海报哦！';
                $this->load->view('cxt/ts', $da);
            }
        } else {
            $this->pub->logq('获取二维码海报');
            $da['msg'] = '二维码18：08开放！';
            $this->load->view('cxt/ts', $da);
        }

    }


    function out()
    {
        $img_url = './upfiles/member/' . $this->config->item('qrcode_pay') . '/' . $this->session->userdata('mid') . '.png';
        @unlink($img_url);

        $this->db->select('openid');
        $q = $this->db->get_where('member', array('mid' => $this->session->userdata('mid')));
        $ls = $q->row_array(0);
        $m = $this->pub->get_member($ls['openid'], TRUE);
        $this->session->sess_destroy();
        redirect('/ashop');
    }

}

?>
